package io.seata.factoryservice.controller;

import io.seata.factoryservice.entity.EquipmentMessage;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by IntelliJ IDEA.
 *
 * @Author : author
 * @create 2022/8/22 16:55
 */
@RestController
public class ReceiveMessageController {

    @Autowired
    RabbitTemplate rabbitTemplate;

    @RequestMapping("/receivenaohmessage")
    public String naohProduction(@RequestBody EquipmentMessage equipmentMessage) {
        rabbitTemplate.convertAndSend("exchangetopic", "naoh", equipmentMessage);
        return "naohproduction ok";
    }

    @RequestMapping("/receivenahco3message")
    public String nahco3Production(@RequestBody EquipmentMessage equipmentMessage) {
        rabbitTemplate.convertAndSend("exchangetopic", "nahco3", equipmentMessage);
        return "nahco3production ok";
    }

    @RequestMapping("/receivenh3message")
    public String nh3Production(@RequestBody EquipmentMessage equipmentMessage) {
        rabbitTemplate.convertAndSend("exchangetopic", "nh3", equipmentMessage);
        return "nh3production ok";
    }
}
